{% extends "base.html" %}
{% load staticfiles %}


{% block title %}
	图灵系统 - 问题详情
{% endblock %}

{% block style %}
{% endblock %}


{% block content %}
<div class="container question" >
	<div class="container " style="width: 100%">
		<!--问题区-->
		<div class="question_summary" >
			<div id="question-header" style="padding-bottom: 25px;">
				{% if Login %}
				<div style="margin: 5px 2px; " class="pull-right">

					<button onclick="likeit()" type="button" class="btn btn-default btn-sm pull-right" style="padding: 1px 6px;padding-top:6px;">
						{% if Liked %}
						<span class="glyphicon glyphicon-heart " id="like" style="color:#f83939"></span itemprop="likeCount">
						{% else %}
						<span class="glyphicon glyphicon-heart " id="like" ></span itemprop="likeCount">
						{% endif %}
					</button>
				</div>
				{% endif %}
		        <h1 itemprop="name" style="color:  #313c2c; font-weight: bold; ">
		        	<span class="question-hyperlink" style="font-size: 23px">
		        		【问题】
		        		<span class="glyphicon glyphicon-hand-right"></span>
		        		 {{question.QuestionAbstract}}
		        		<span class="glyphicon glyphicon-hand-left"></span>
		        	</span>
		        </h1>

		        <label>&nbsp;&nbsp;&nbsp;标签：</label>
		        {% for tag in tags %}
		        	<a href="" class="sum_post-tag" title="" rel="">{{tag}}</a>
		        {% endfor %}
			</div>

			<div  class="transition" >
		        	<!--img src="{% static 'image/gray.png' %}"-->
		  </div>

			<div class="comment-box" style="margin-top: 10px;">

			<br>
				<div class="comment-box_left" style="">
					<img src="{{avatar}}" class="img-responsive" alt="" >
				</div>
				<div class="comment-box_right">
					<p style="font_weight:bold;color:#313c2c; ">
						<span  class="floor" >楼主</span>
						<label>{{question.QuizzerName}}</label>
						<!-- <a href="/name">{{question.QuizzerName}}</a> -->
						<span class="pull-right" style="font-weight:bold; font-size: 14px">
							<span title="2016-11-22 16:41:53Z" class="relativetime">
								{{questionTime}}
							</span>
						</span>
					</p>
					<div style="padding-top: 20px;">
				    	<div class="post-text" itemprop="text" style="float:left;width:90%;">
							<p>{{question.QuestionContent|safe}}</p>
							</div>
					</div>
						{% if Login %}
				    <div class="pull-right" style="width: 100%">
							<td class="votecell" style="float:left;width:8%; margin-right: 2%" >
								<div class="vote">
								    <input type="hidden" name="_id_" value="40747226">

								    <div style="padding: 2px; "  align="right">
									    <button onclick="QuestionPraise()" type="button" class="btn btn-default btn-sm ">
											<span class="glyphicon glyphicon-thumbs-up" style="padding-top: 8px； font-size: 16px">
											</span itemprop="upCount">
											&emsp;
											<span id="QuestionPraise" style="font-size: 13px">
												{{question.PraiseNum}}
											</span>
											</button>
										</div>

									<div style="padding: 2px; " align="right">
										<button onclick="QuestionOppose()" id="{{question.QuestionID}}" type="button" class="btn btn-default btn-sm QuestionOpperation ">
											<span class="glyphicon glyphicon-thumbs-down"  style="padding-top: 8px； font-size: 16px">
											</span itemprop="downCount">
											&emsp;
											<span id="QuestionOppose" style="font-size: 13px ">
												{{question.OpposeNum}}
											</span>
										</button>
									</div>
									{% if Owned %}
									<div style="padding: 2px; " align="right">
										<button onclick="QuestionDelete()" id="{{question.QuestionID}}" type="button" class="btn btn-default btn-sm QuestionOpperation ">
											<span class="glyphicon glyphicon-remove"  style="padding-top: 8px； font-size: 16px">
											</span itemprop="downCount">

											<span style="font-size: 12px ">
												删除
											</span>
										</button>
									</div>
									{% endif %}
									</div>
				          </td>
					    </div>
							{% endif %}

						<br>




					<div class="clearfix"></div>

				</div>
			</div>


		</div>

		<div  class="transition" >
		        	<!--img src="{% static 'image/gray.png' %}"-->

		</div>


		<!--评论区-->
		<div class="comment_section">
		 	<h3 style="color:  #313c2c;
		 			font-weight: bold;
		 			border-bottom: 1px solid #eee;
		 			padding-bottom: 5px">
		 		{{question.AnswerNum}}个回答
		 	</h3>
		 	<ul class="comment-list">
		 		{% for answer in answers %}
          <li style=" padding-top:15px; padding-bottom:5px;border-bottom: 1px solid #eee;">
			     	<div class="comment-box">
							{% if answer.IsAccepted %}
							<span>这个答案被采纳了</span>
							{% endif %}
			       		<div class="comment-box_left">
			       			<img src="{{answer.avatar}}" class="img-responsive" style="width:70%" alt=""/>
			       		</div>
			        	<div class="comment-box_right">
			        		<span class="floor" >回答者</span><lable style="font-weight:bold; font-size: 16px;">
			        			<a href="#">
			        				{{answer.ResponderName}}
			        			</a></lable>
			        			<span class="pull-right" style="font-weight:bold;font-size: 14px">

			        				<span title="2016-11-22 16:41:53Z" class="relativetime">
			        					{{answer.answerTime}}
			        				</span>
			        			</span>
			        		</h5>
		            		<p>{{answer.AnswerContent|safe}}</p>
							{% if Login %}
							<span class="pull-right">

								<td class="votecell">
							    <div class="vote">
							      <div style="margin: 2px" align="right">
								      <button id="{{answer.AnswerID}}" type="button" class="btn btn-default btn-sm AnswerPraise">
										  		<span class="glyphicon glyphicon-thumbs-up" style="padding-top: 8px； font-size: 16px">


										  		</span itemprop="upCount">
										  		&emsp;
										  		<span id="{{answer.AnswerID}}" class="Praise" style="font-size: 13px ">
									  				{{answer.PraiseNum}}
									  			</span>
											</button>
										</div>
										<div style="margin: 2px" align="right">
											<button type="button" id="{{answer.AnswerID}}" class="btn btn-default btn-sm AnswerOppose">
										  		<span class="glyphicon glyphicon-thumbs-down" style="padding-top: 8px； font-size: 16px">
										  		</span itemprop="downCount">
										  		&emsp;
										  		<span id="{{answer.AnswerID}}" class="Oppose" style="font-size: 13px ">
									  				{{answer.OpposeNum}}
									  			</span>
											</button>
										</div>

										{% if answer.Owned %}
										<div style="margin: 2px  " align="right">
											<button type="button" id="{{answer.AnswerID}}" class="btn btn-default btn-sm AnswerDelete">
										  		<span style="font-size: 12px ">
									  				删除
									  			</span>
											</button>
										</div>
										{% endif %}
										{% if not question.AcceptedAnswerID and Owned %}
										<div style="margin: 2px  " align="right">
											<button type="button" id="{{answer.AnswerID}}" class="btn btn-default btn-sm AcceptAnswer">
										  		<span style="font-size: 12px ">
									  				采纳
									  			</span>
											</button>
										</div>
										{% endif %}
									</div>
			            </td>

			        </span>
							{% endif %}
			        </div>
			      	</div>
			      	<div class="clearfix"> </div>
				</li>
				{% endfor %}
	    	</ul>
    	</div>
        <!--我的回复-->
        {% if Login %}
        <div id="mainbar" class="container question question-detail-mainbar" >
			<form id="post-form" class="post-form" action="/answerSubmit/" method="post" onsubmit="return myonsubmit(event)">
    			<input type="hidden" name="qualityBanWarningShown" value="False"/>
    			<input type="hidden" name="priorAttemptCount" value="0"/>
    			<input type="hidden" name="warntags" />
    			<input name="qID" type="text" style="display:none;" value="{{question.QuestionID}}" />
				<div id="post-editor" >
					<div style="position: relative;">
		            	<table>
		            		<tr>
                				<h3 style="color:  #313c2c; font-weight: bold;">
                    				我的评论
                				</h3>
            				</tr>
                     	   	<tr>
				  				<textarea cols="80" id="content" name="post-text" class="ckeditor" rows="10"></textarea>
						    	<script type="text/javascript">
	 					    		function getContent(){
				        				return CKEDITOR.instances.content.getBody().getText();
				        			}
				   				</script>
              				</tr>
		        		</table>
					</div>
				</div>
        		<div style="">
        			<br>
            		<div id="question-only-section" class="pull-right" >
			    		<div class="form-item" style="">
			    			{% if not Liked %}
			        		<td>
			            		<input name="receive_email" type="checkbox"/>
			            		<label for="" class="chkbx_text" style="display: inline">
			            			邮箱接收最新回复
			            		</label>
			        		</td>
			        		{% endif %}
			        		<!-- <td>
			            		<input id="" type="checkbox"/>
			            		<label for="" class="chkbx_text" style="display: inline">
			            			匿名发布
			            		</label>
							</td> -->
			        		<td>
			        			<button id="submit-button" class="form-sumbit" >发布</button>
			        		</td>
			        	</div>
              		</div>
    			</div>
			</form>
		</div>
		{% else %}
		<br>
		<div style="text-align: center;color: #930000;">
			<label>登录后可参与评论噢！~</label>
		</div>
		<br>
		{% endif %}

	</div>
</div>

{% endblock %}



{% block other_script %}
<script type="text/javascript" src="{%static 'ckeditor/ckeditor.js' %}"></script>
<script type="text/javascript" src = "{% static 'js/buttonFunctions.js' %}" ></script>
<script type="text/javascript">
function myonsubmit(event) {
	// body...
	var reg=/^((<p>(\&nbsp;( )?)*<\/p>)*\n?)*$/;
	if (reg.test(CKEDITOR.instances.content.getData())) {
		window.alert("问题详情不能为空！");
		return false;
	}
	$('#post-form').find('button[id="submit-button"]').attr('disabled','disabled');
	return true;
		//document.getElementById('post-form').submit();
}
/*
	$('#post-form').one('submit', function() {
		console.log("11111");
		var reg=/^((<p>(\&nbsp;( )?)*<\/p>)*\n?)*$/;
		if (reg.test(CKEDITOR.instances.content.getData())) {
			window.alert("问题详情不能为空！");
			return false;
		}
		$(this).find('button[id="submit-button"]').attr('disabled','disabled');
		return true;
	});*/
</script>

<!-- code_highlight -->
<script type="text/javascript" src="{%static 'code_highlight/power.js' %}"></script>
<script type="text/javascript" src="{%static 'code_highlight/prettify.js' %}"></script>
<link rel="stylesheet" type="text/css" href="{%static 'code_highlight/font-awesome.min.css' %}"/>
<link rel="stylesheet" type="text/css" href="{%static 'code_highlight/prettify.css' %}"/>
<link rel="stylesheet" type="text/css" href="{%static 'code_highlight/style_2.css' %}"/>
{% endblock %}
